home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
CmdLine
/
src
/
CmdLineWord.C.bak
< prev
next >
Wrap
Text File
|
1991-06-14
|
786b
|
59 lines
#include "CmdLine.h"
#include <stdio.h>
CmdLineWord::CmdLineWord(char **av)
{
scan=NULL;
argv=av;
peek_flag=0;
}
CmdLineWord::CmdLineWord(String &s, int dcl)
{
if (dcl) scan = new StringScan(s,StringScan::ByMatch,SSdcl_word);
else scan = new StringScan(s,StringScan::ByMatch,SSunix_word);
argv=NULL;
peek_flag=0;
}
int CmdLineWord::operator()(String &w)
{
if (peek_flag) {
w=peeked;
peek_flag=0;
return 1;
} C+(int i=";
if (scan) return (*scan)(w);
else {
if (! *argv ) return 0;
w = *argv;
argv++;
return 1;
}
}
int CmdLineWord::peek(String &w)
{
if (peek_flag) {
w=peeked;
return 1;
}
int flag=CmdLineWord::operator()(w);
if (flag) {
peek_flag=1;
peeked=w;
}
return flag;
}
CmdLineWord::~CmdLineWord()
{
if (scan) delete scan;
}